package com.yunxi.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.order.pojo.TrRefundVO;
import com.yunxi.order.service.TrRefundDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 订单退款表 前端控制器
 * </p>
 *
 * @author
 * @since 2019-09-09
 */
@RestController
@RequestMapping("/admin/trrefund")
@Api(tags = "pms:trrefund", description = "订单退款表接口")
public class TrRefundController {
   private static final Logger logger = LoggerFactory.getLogger(TrRefundController.class);

   @Autowired
   TrRefundDubboService trRefundDubboService;

   @GetMapping("/page")
   @ApiOperation(value = "查询订单退款表分页")
   public ApiResult page(TrRefundVO trRefundVO, Integer pageNum, Integer pageSize) throws Exception {
      return ResponseUtil.ok(trRefundDubboService.findPageByVO(trRefundVO, pageNum, pageSize));
   }

   @GetMapping("/list")
   @ApiOperation(value = "查询订单退款表列表")
   public ApiResult list(TrRefundVO trRefundVO) throws Exception {
      return ResponseUtil.ok(trRefundDubboService.listByVo(trRefundVO));
   }

   @GetMapping("/load")
   @ApiOperation(value = "读取单个订单退款表")
   public ApiResult load(TrRefundVO trRefundVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(trRefundDubboService.getById(String.valueOf(trRefundVO.getId())));
   }

   @PostMapping("/save")
   @ApiOperation(value = "保存订单退款表信息")
   public ApiResult save(@RequestBody TrRefundVO trRefundVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      trRefundDubboService.saveOrUpdate(trRefundVO);
      return ResponseUtil.ok("success");
   }

   @PostMapping("/del")
   @ApiOperation(value = "删除订单退款表")
   public ApiResult del(@RequestBody List<TrRefundVO> trRefundVOList) throws Exception {
      trRefundDubboService.removeByListVo(trRefundVOList);
      return ResponseUtil.ok("success");
   }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(trRefundDubboService.findMapByList(params));
}*/
}
